//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

namespace CommunityServer.Components
{
	public class CSEvents
	{
		private CSEvents(){}

		#region Users
		/// <summary>
		/// Raises all UserValidated events. These events are raised after a users credentials have been validated
		/// </summary>
		/// <param name="user"></param>
		public static void UserValidated(User user)
		{
			CSApplication.Instance().ExecuteUserValidated(user);
		}

		/// <summary>
		/// Raises all UserKnown events. These events are raised the first time CS "recognizes" the current user. 
		/// </summary>
		/// <param name="user"></param>
		public static void UserKnown(User user)
		{
			CSApplication.Instance().ExecuteUserKnown(user);
		}

		/// <summary>
		/// Raises all BeforeUser events. These events are raised before any committements are
		/// made to the User (create or update)
		/// </summary>
		public static void BeforeUser(User user, ObjectState state)
		{
			CSApplication.Instance().ExecutePreUserUpdate(user,state);
		}

		/// <summary>
		/// Raises all AfterUser events. These events are raised after changes (created or update) are 
		/// made to the datastore
		/// </summary>
		public static void AfterUser(User user, ObjectState state)
		{
			CSApplication.Instance().ExecutePostUserUpdate(user,state);
		}

		/// <summary>
		/// Raises all UserRemoved events. These events are raised before the user is removed from the data store
		/// </summary>
		/// <param name="user"></param>
		public static void UserRemoved(User user)
		{
			CSApplication.Instance().ExecuteUserRemove(user);
		}


		#endregion

		#region Posts

		/// <summary>
		/// Raises all AuthorizePost events. These events are raised before a user can access a page (control) 
		/// which includes allows new content to be posted.
		/// </summary>
		public static void AuthorizePost()
		{
			CSApplication.Instance().ExecuteAuthorizePost();
		}

		/// <summary>
		/// Raises all PrePost events. These events are raised before a post reaches BeforePost
		/// </summary>
		public static void PrePost(IContent content, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePrePostEvents(content,state,appType);
		}

		/// <summary>
		/// Raises all BeforePost events. These events are raised before a post is commited to the datastore
		/// </summary>
		public static void BeforePost(IContent content, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePrePostUpdateEvents(content,state,appType);
		}

		/// <summary>
		/// Raises all AfterPost events. These events are raised after a post is committed to the datastore
		/// </summary>
		public static void AfterPost(IContent content, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePostPostUpdateEvents(content,state,appType);
		}

		/// <summary>
		/// Raises all BeforePostAttachment events. These events are raised after a post is commited to the datastore but before the Attachment is commited
		/// </summary>
		public static void BeforePostAttachment(IContent content, PostAttachment attachment, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePrePostAttachmentUpdateEvents(content,attachment,state,appType);
		}

		/// <summary>
		/// Raises all AfterPostAttachment events. These events are raised after a post is committed to the datastore and after the Attachment is commited
		/// </summary>
		public static void AfterPostAttachment(IContent content, PostAttachment attachment, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePostPostAttachmentUpdateEvents(content,attachment,state,appType);
		}


		/// <summary>
		/// Raises all PreRenderPost events. These events should be raised before the post is rendered
		/// </summary>
		public static void PreRenderPost(IContent content, ApplicationType appType, PostTarget target)
		{
			CSApplication.Instance().ExecutePrePostRender(content,appType,target);
		}
		#endregion

		#region Sections

		/// <summary>
		/// Raises all BeforeSection events. These events are raised before a section is commited to the datastore
		/// </summary>
		public static void BeforeSection(Section section, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePreSectionUpdate(section,state,appType);
		}

		/// <summary>
		/// Raises all AfterSection events. These events are raised after a section is commited to the datastore
		/// </summary>
		public static void AfterSection(Section section, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePostSectionUpdate(section,state,appType);
		}

		#endregion

		#region Groups

		/// <summary>
		/// Raises all BeforeGroup events. These events are raised before a group change is commited to the datastore
		/// </summary>
		public static void BeforeGroup(Group group, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePreSectionGroupUpdate(group,state,appType);
		}

		/// <summary>
		/// Raises all AfterGroup events. These events are raised after a group change is commited to the datastore
		/// </summary>
		public static void AfterGroup(Group group, ObjectState state, ApplicationType appType)
		{
			CSApplication.Instance().ExecutePostSectionGroupUpdate(group,state,appType);
		}

		#endregion

		#region PostCategories

		public static void CategoryUpdated(PostCategory category)
		{
			CSApplication.Instance().ExecuteCategoryUpdated(category);
		}

		public static void CategoryRemoved(PostCategory category)
		{
			CSApplication.Instance().ExecuteCategoryRemoved(category);
		}

		#endregion

		#region Ratings

		public static void Rate(Rating rating, ApplicationType appType)
		{
			CSApplication.Instance().ExecuteRateEvents(rating, appType);
		}

		#endregion

		#region Favorites

		public static void FavoriteAdded(Favorite favorite, ApplicationType appType)
		{
			CSApplication.Instance().ExecuteFavoriteAdded(favorite, appType);
		}

		public static void FavoriteRemoved(Favorite favorite, ApplicationType appType)
		{
			CSApplication.Instance().ExecuteFavoriteRemoved(favorite, appType);
		}

		#endregion

		#region Exceptions

		public static void CSException(CSException csEx)
		{
			CSApplication.Instance().ExecuteCSExcetion(csEx);
		}

		#endregion

        #region Search

        public static void PreSearch(SearchQuery query)
        {
            CSApplication.Instance().ExecutePreSearch(query);
        }

        public static void PostSearch(SearchResultSet results)
        {
            CSApplication.Instance().ExecutePostSearch(results);
        }

        #endregion

		#region UserInvitations

		public static void BeforeUserInvitation(UserInvitation invitation, ObjectState state)
		{
			CSApplication.Instance().ExecutePreUserInvitationUpdate(invitation, state);
		}

		public static void AfterUserInvitation(UserInvitation invitation, ObjectState state)
		{
			CSApplication.Instance().ExecutePostUserInvitationUpdate(invitation, state);
		}

		public static void AcceptUserInvitation(UserInvitation invitation, User userAccepted)
		{
			CSApplication.Instance().ExecuteUserInvitationAccepted(invitation, userAccepted);
		}

		#endregion

        public static void PostConfigurationInitialized(object configurationObject)
        {
            CSApplication.Instance().ExecuteConfigurationInitilized(configurationObject);
        }

	}
}
